using System.Data.Entity.ModelConfiguration;
using PhoneBook.Core.Domain.Phones;

namespace PhoneBook.Data.Mapping
{
    public class PhoneMap : EntityTypeConfiguration<Phone>
    {
        public PhoneMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.PhoneNumber)
                .HasMaxLength(30);

            // Table & Column Mappings
            this.ToTable("Phones");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.PhoneType).HasColumnName("PhoneType");
            //this.Property(t => t.Contact_Id).HasColumnName("Contact_Id");
            this.Property(t => t.PhoneNumber).HasColumnName("PhoneNumber");

            // Relationships
            this.HasOptional(t => t.Contact)
                .WithMany(t => t.Phones);
                //.HasForeignKey(d => d.Contact_Id);

        }
    }
}
